#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int N;
	int ret = 0;
	cin >> N;

	vector<int> num;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}

	sort(num.begin(), num.end());
	for (auto e : num) {
		if (num[N - 1] - e < N) {
			ret++;
		}
		
	}
	cout << ret << endl;
}